import { reqGoodsList } from '@/api'

let state = {
  searchList: {}
}

let mutations = {
  GETGOODSLIST(state, data) {
    state.searchList = data
  }
}

let actions = {
  async getGoodsList({ commit }, params) {
    let result = await reqGoodsList(params || {})
    console.log(result)
    if (result.code === 200) {
      commit('GETGOODSLIST', result.data)
    }
  }
}

//getters:仓库的计算属性
let getters = {
  goodsList(state) {
    //state,当前小仓库的数据
    return state.searchList.goodsList || []
  },
  trademakeList(state) {
    return state.searchList.trademarkList || []
  },
  attrsList(state) {
    return state.searchList.attrsList || []
  }
}

export default {
  state,
  mutations,
  actions,
  getters
}
